package main

import (
	"math/rand"
	"fmt"
	"time"
	"strconv"
)

func main() {
	myRand := rand.New(rand.NewSource(time.Now().UnixNano()))
	answer := myRand.Intn(1000)

	for{
		//接受用户的输入
		fmt.Println("请输入你的猜想：")
		var guess string
		fmt.Scan(&guess)

		//用户想要提前退出
		if guess == "fuckoff"{
			break
		}

		//转换为整数
		guessNum, _ := strconv.Atoi(guess)

		//反馈猜测的结果
		switch {
		case guessNum > answer:
			fmt.Println("猜大了")
		case guessNum < answer:
			fmt.Println("猜小了")
		default:
			fmt.Println("猜对了")
			break
		}
	}


}
